#include "appsetting.h"
//

AppSetting::AppSetting( QWidget* parent )
	: QWidget( parent )
{
	setupUi( this );
	FillData();
}

void AppSetting::FillData() 
{
    const QString usersetfont = setter.value("DefaultFontsW").toString();
	  Carattere->setText(tr("%1 / Seleziona...").arg(usersetfont));
	
	     if (usersetfont.size() > 0 ) {
            settfont.fromString(usersetfont);
           //// setFont(settfont);
        }
    //////////QStringList  xxtaxTypes = setter.value("books/typelist").toStringList();   /* typtax */
    //////////QStringList  xxnameTypes = setter.value("books/accountinglist").toStringList();  /* typbook */
				
				
	  if (setter.value("db/master").toString().size() > 0) {
    QString  dbmaster = decodeBase64(setter.value("db/master").toString());
			connectings->setText(dbmaster);
		}
		if (setter.value("tijava/user").toString().size() > 0) {
			tiuser->setText(decodeBase64(setter.value("tijava/user").toString()));
		}
		if (setter.value("tijava/pass").toString().size() > 0) {
			tipass->setText(decodeBase64(setter.value("tijava/pass").toString()));
		}
		
		if (setter.value("pm/serial").toString().size() > 0) {
			paserial->setText(decodeBase64(setter.value("pm/serial").toString()));
		}
		if (setter.value("pm/host").toString().size() > 0) {
			pahost->setText(decodeBase64(setter.value("pm/host").toString()));
		}
		
    /////////QString  dbslave = decodeBase64(setter.value("db/slave").toString());
    //////////appsex->setText(setter.fileName());
    ////QString serialNN = setter.value("apps/serial").toString();
    ////QString dirsie = setter.value("template/sie").toString();
    /////QString dirdu = setter.value("template/du").toString();
	  if (setter.value("apps/nota").toString().size() > 0) {
    QString nota = decodeBase64(setter.value("apps/nota").toString());
    textEdit->setHtml(nota);
		}
}

void AppSetting::on_SalvaSetting_clicked()
{
    setter.setValue("db/master",encodeBase64(connectings->text()));
    setter.setValue("apps/nota",encodeBase64(textEdit->toHtml()));
	
	  setter.setValue("tijava/user",encodeBase64(tiuser->text()));
		setter.setValue("tijava/pass",encodeBase64(tipass->text()));
		setter.setValue("pm/serial",encodeBase64(paserial->text()));
		setter.setValue("pm/host",encodeBase64(pahost->text()));
    emit NewData();
}




void AppSetting::on_Carattere_clicked()
{
  bool ok;
  QFont fontyour = QFontDialog::getFont(&ok,settfont,0);
  if (ok) {
   setter.setValue("DefaultFontsW",fontyour.toString());  
   QApplication::setFont(fontyour);
		  const QString usersetfont = setter.value("DefaultFontsW").toString();
	    Carattere->setText(tr("%1 / Seleziona...").arg(usersetfont));
  }
}





